import os, time
if __name__ == '__main__':
    start = time.time()
    directory = "C:\\Users\\metype\\Desktop\\alipay.trade.wap.pay-java-utf-8"
    for cdir, subdirs, files in os.walk(directory):
        for file in files:
            if file.endswith(".java"):
                print(file)
                try:
                    bom_file = os.path.join(cdir, file)
                    s = open(bom_file, mode='r', encoding='utf-8-sig').read()
                    open(bom_file, mode='w', encoding='utf-8').write(s)
                except Exception:
                    print("出问题"+file)
    print("cost time: %.3fs" % (time.time() - start))
